<?php

class DB_Class_PDO {
 	/*
 	private $dbh;	

 	function __construct() {
		$dsn = db_driver.':host='.db_host.';dbname='.db_name;
	
 		if(empty($this->dbh)) {
 			$this->dbh = new PDO($dsn, db_user, db_pass);

            $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);                                                                     
            $this->dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);       
 		
 			$this->dbh->query("SET NAMES 'utf8'");
    		$this->dbh->query("SET CHARACTER SET 'utf8'");
    		$this->dbh->query("SET SESSION collation_connection = 'utf8_general_ci'");
 			$this->dbh->query("SHOW VARIABLES LIKE 'UTF-8'");
 		}
 		
		return $this->dbh;
 		
 	}
	function pdo () {
		return $this->dbh;
	}
	*/
	
	 static private $dbh = NULL;

     private function __construct() {

		$dsn = db_driver.':host='.db_host.';dbname='.db_name;
	
// 		if(empty($this->dbh)) {
 			self::$dbh = new PDO($dsn, db_user, db_pass);

            self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);                                                                     
            self::$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);       
 		
 			self::$dbh->query("SET NAMES 'utf8'");
    		self::$dbh->query("SET CHARACTER SET 'utf8'");
    		self::$dbh->query("SET SESSION collation_connection = 'utf8_general_ci'");
 			self::$dbh->query("SHOW VARIABLES LIKE 'UTF-8'");
// 		}
     	
     }

     static public function getInstance() {
         if (self::$dbh == NULL) {
//             self::$dbh =
              new DB_Class_PDO();
         }
         
//         print_r(self::$dbh);
         
         return self::$dbh;
     }
}

?>
